from django.urls import include, path
from apps.app.utils.router import Router
from apps.app import views
from rest_framework_simplejwt.views import (
    TokenObtainPairView,
    TokenRefreshView,
    TokenVerifyView
)


router = Router()
router.register('users', views.UserViewSet)
router.register('groups', views.GroupViewSet)
router.register('menu', views.MenuViewSet)
router.register('dept', views.DeptViewSet)
router.register('role', views.RoleViewSet)
router.register('staff', views.StaffViewSet)
router.register('device', views.DeviceViewSet)
router.register('deviceCkeck', views.DeviceCheckViewSet)
router.register('deviceCkeckAll', views.DeviceCheckAllViewSet)
router.register('deviceSoft', views.DeviceSoftViewSet)
router.register('agreement', views.AgreementViewSet)
router.register('auth', views.AuthViewSet)
router.register('leader', views.LeaderViewSet)
router.register('apply', views.ApplyViewSet)
router.register('purchase', views.PurchaseViewSet)
router.register('duty', views.DutyViewSet)
router.register('hardware', views.HardwareViewSet)
router.register('hardwarePurchase', views.HardwarePurchaseViewSet)
router.register('supplier', views.SupplierViewSet)
router.register('dict', views.DictViewSet)
router.register('dictData', views.DictDataViewSet)

# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
''' path
    Django 2.2.x 之后的版本
    path：用于普通路径，不需要自己手动添加正则首位限制符号，底层已经添加。
    re_path：用于正则路径，需要自己手动添加正则首位限制符号。 
    正则： (?P<组名>正则表达式)
    路由分发(include)
'''
urlpatterns = [
    path('', include(router.urls)),
    # DRF 提供的一系列身份认证的接口，用于在页面中认证身份，详情查阅DRF文档
    #path('auth/', include('rest_framework.urls', namespace='rest_framework')),
    path('token/', TokenObtainPairView.as_view(), name='token_obtain_pai'),
    path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('token/verify/', TokenVerifyView.as_view(), name='token_verify'),
]